/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as math from './mathjs/index.js';
import { mathData } from "./mathData.js";

function bitAnd_Test() {
    let result;
    const bitAndStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.bitAnd(6847328908439004, 4384901892789312);
    }
    const bitAndEndTime = Date.now();
    if (result != -2026814400) {
        throw Error('math_bitAnd error');
    }
    print(`math_bitAnd: ${bitAndEndTime - bitAndStartTime} ms`);
}

function bitNot_Test() {
    let result;
    const bitNotStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.bitNot(6847328908439004);
    }
    const bitNotEndTime = Date.now();
    if (result != 12620323) {
        throw Error('math-bitNot error');
    }
    print(`math-bitNot: ${bitNotEndTime - bitNotStartTime} ms`);
}

function bitOr_Test() {
    let result;
    const bitOrStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.bitOr(6847328908439004, 4384901892789312);
    }
    const bitOrEndTime = Date.now();
    if (result != -4194852) {
        throw Error('math-bitOr error');
    }
    print(`math-bitOr: ${bitOrEndTime - bitOrStartTime} ms`);
}

function bitXor_Test() {
    let result;
    const bitXorStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.bitXor(6847328908439004, 4384901892789312);
    }
    const bitXorEndTime = Date.now();
    if (JSON.stringify(result) != '2022619548') {
        throw Error('math-bitXor error');
    }
    print(`math-bitXor: ${bitXorEndTime - bitXorStartTime} ms`); 
}

function isZero_Test() {
    let result;
    const isZeroStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.isZero([10, 0, -10]);    
    }
    const isZeroEndTime = Date.now();
    if (JSON.stringify(result) != '[false,true,false]') {
        throw Error('math-isZero error');
    }
    print(`math-isZero: ${isZeroEndTime - isZeroStartTime} ms`);
}

function isPrime_Test() {
    let result;
    const isPrimeStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.isPrime([10, 2, 179424673]);   
    }
    const isPrimeEndTime = Date.now();
    if (JSON.stringify(result) != '[false,true,true]') {
        throw Error('math-isPrime error');
    }
    print(`math-isPrime: ${isPrimeEndTime - isPrimeStartTime} ms`);
}

function isNumeric_Test() {
    let result;
    const isNumericStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.isNumeric([10, '1a2b3c', true]);
    }
    const isNumericEndTime = Date.now();
    if (JSON.stringify(result) != '[true,false,true]') {
        throw Error('math-isNumeric error');
    }
    print(`math-isNumeric: ${isNumericEndTime - isNumericStartTime} ms`);
}

function isNaN_Test() {
    let result;
    const isNaNStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.isNaN([10, NaN, '0']);
    }
    const isNaNEndTime = Date.now();
    if (JSON.stringify(result) != '[false,true,false]') {
        throw Error('math-isNaN error');
    }
    print(`math-isNaN: ${isNaNEndTime - isNaNStartTime} ms`);
}

function isInteger_Test() {
    let result;
    const isIntegerStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.isInteger([10, 1.3, NaN]);
    }
    const isIntegerEndTime = Date.now();
    if (JSON.stringify(result) != '[true,false,false]') {
        throw Error('math-isInteger error');
    }
    print(`math-isInteger: ${isIntegerEndTime - isIntegerStartTime} ms`);
}

function hasNumericValue_Test() {
    let result;
    const hasNumericStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.hasNumericValue([1.3, '13abc', true]);
    }
    const hasNumericEndTime = Date.now();
    if (JSON.stringify(result) != '[true,false,true]') {
        throw Error('math-hasNumeric error');
    }
    print(`math-hasNumeric: ${hasNumericEndTime - hasNumericStartTime} ms`);
}

function variance_Test() {
    let result;
    const varianceStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.variance([1, 2, 3, 4, 5], 0, 'uncorrected');
    }
    const varianceEndTime = Date.now();
    if (JSON.stringify(result) != '2') {
        throw Error('math-variance error');
    }
    print(`math-variance: ${varianceEndTime - varianceStartTime} ms`);
}

function sum_Test() {
    let result;
    const sumStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.sum([5786897686543565, -1232132543122134]);
    }
    const sumEndTime = Date.now();
    if (result.toString() != '4554765143421431') {
        throw Error('math-sum error');
    }
    print(`math-sum: ${sumEndTime - sumStartTime} ms`);
}

function prod_Test() {
    let result;
    const prodStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.prod([[2, 1, 3], [1, 10, 1], [10, 1, 10]]);
    }
    const prodEndTime = Date.now();
    if (JSON.stringify(result) != '6000') {
        throw Error('math-prod error');
    }
    print(`math-prod: ${prodEndTime - prodStartTime} ms`);
}

function mean_Test() {
    let result;
    const meanStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.mean([[2, 5, 8], [6, 1, 5], [1, 3, 8]], 1);
    }
    const meanEndTime = Date.now();
    if (JSON.stringify(result) != '[5,4,4]') {
        throw Error('math-mean error');
    }
    print(`math-mean: ${meanEndTime - meanStartTime} ms`);
}

function mad_Test() {
    let result;
    const madStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.mad([[2, 5, 3], [6, 3, 4], [1, 7, 5]]);
    } 
    const madEndTime = Date.now();
    if (JSON.stringify(result) != '1') {
        throw Error('math-mad error');
    }
    print(`math-mad: ${madEndTime - madStartTime} ms`);
}

function cumsum_Test() {
    let result;
    const cumsumStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.cumsum([[1, 2, 3], [4, 5, 6], [7, 8, 9], [2, 5, 3], [6, 3, 4], [1, 7, 5]]);
    }
    const cumsumEndTime = Date.now();
    if (JSON.stringify(result) != '[[1,2,3],[5,7,9],[12,15,18],[14,20,21],[20,23,25],[21,30,30]]') {
        throw Error('math-cumsum error');
    }
    print(`math-cumsum: ${cumsumEndTime - cumsumStartTime} ms`);
}

function isNegative_Test() {
    let result;
    const isNegativeStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.isNegative([-5, 5]);
    }
    const isNegativeEndTime = Date.now();
    if (JSON.stringify(result) != '[true,false]') {
        throw Error('math-isNegative error');
    }
    print(`math-isNegative: ${isNegativeEndTime - isNegativeStartTime} ms`);
}

function isPositive_Test() {
    let result;
    const isPositiveStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.isPositive([-5, 5]);
    }
    const isPositiveEndTime = Date.now();
    if (JSON.stringify(result) != '[false,true]') {
        throw Error('math-isPositive error');
    }
    print(`math-isPositive: ${isPositiveEndTime - isPositiveStartTime} ms`);
}

function unaryMinus_Test() {
    let result;
    const unaryMinusStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.unaryMinus([12, -12, 0]);
    }
    const unaryMinusEndTime = Date.now();
    if (JSON.stringify(result) != '[-12,12,0]') {
        throw Error('math-unaryMinus error');
    }
    print(`math-unaryMinus: ${unaryMinusEndTime - unaryMinusStartTime} ms`);
}

function tan_Test() {
    let result;
    const tanStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.tan(0.786);
    }
    const tanEndTime = Date.now();
    if (result.toFixed(6).toString() != '1.001204') {
        throw Error('math-tan error');
    }
    print(`math-tan: ${tanEndTime - tanStartTime} ms`);
}

function subtract_Test() {
    let result;
    const subtractStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.subtract(13, 2);
    }
    const subtractEndTime = Date.now();
    if (result.toString() != '11') {
        throw Error('math-subtract error');
    }
    print(`math-subtract: ${subtractEndTime - subtractStartTime} ms`);
}

function sqrt_Test() {
    let result;
    const sqrtStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.sqrt(1522756);
    }
    const sqrtEndTime = Date.now();
    if (result.toString() != '1234') {
        throw Error('math-sqrt error');
    }
    print(`math-sqrt: ${sqrtEndTime - sqrtStartTime} ms`);
}

function sin_Test() {
    let result;
    const sinStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.sin(0.524);
    }
    const sinEndTime = Date.now();
    if (result.toFixed(6).toString() != '0.500347') {
        throw Error('math-sin error');
    }
    print(`math-sin: ${sinEndTime - sinStartTime} ms`);
}

function round_Test() {
    let result;
    const roundStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.round([5.7612, 5.3324], 1);
    }
    const roundEndTime = Date.now();
    if (JSON.stringify(result) != '[5.8,5.3]') {
        throw Error('math-round error');
    }
    print(`math-round: ${roundEndTime - roundStartTime} ms`);
}

function rightArithShift_Test() {
    let result;
    const rightArithShiftStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.rightArithShift(6847328908439004, 6);
    }
    const rightArithShiftEndTime = Date.now();
    if (result.toString() != '-197193') {
        throw Error('math-rightArithShift error');
    }
    print(`math-rightArithShift: ${rightArithShiftEndTime - rightArithShiftStartTime} ms`);
}

function multiply_Test() {
    let result;
    const multiplyStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.multiply(12345, 12345678);
    }
    const multiplyEndTime = Date.now();
    if (result.toString() != '152407394910') {
        throw Error('math-multiply error');
    }
    print(`math-multiply: ${multiplyEndTime - multiplyStartTime} ms`);
}

function min_Test() {
    let result;
    const minStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.min(1, 2, -3, 4, 5);
    }
    const minEndTime = Date.now();
    if (result.toString() != '-3') {
        throw Error('math-min error');
    }
    print(`math-min: ${minEndTime - minStartTime} ms`);
}

function max_Test() {
    let result;
    const maxStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.max(1, 2, -3, 4, 5);
    }
    const maxEndTime = Date.now();
    if (result.toString() != '5') {
        throw Error('math-max error');
    }
    print(`math-max: ${maxEndTime - maxStartTime} ms`);
}

function log_Test() {
    let result;
    const logStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.log(10);
    }
    const logEndTime = Date.now();
    if (result.toFixed(6).toString() != '2.302585') {
        throw Error('math-log error');
    }
    print(`math-log: ${logEndTime - logStartTime} ms`);
}

function leftShift_Test() {
    let result;
    const leftShiftStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.leftShift(6847328908439004, 6);
    }
    const leftShiftEndTime = Date.now();
    if (result.toString() != '-807700736') {
        throw Error('math-leftShift error');
    }
    print(`math-leftShift: ${leftShiftEndTime - leftShiftStartTime} ms`);
}

function exp_Test() {
    let result;
    const expStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.exp(2.12);
    }
    const expEndTime = Date.now();
    if (result.toFixed(6).toString() != '8.331137') {
        throw Error('math-exp error');
    }
    print(`math-exp: ${expEndTime - expStartTime} ms`);
}

function divide_Test() {
    let result;
    const divideStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.divide(5786897686543565, 5);
    }
    const divideEndTime = Date.now();
    if (result.toString() != '1157379537308713') {
        throw Error('math-divide error');
    }
    print(`math-divide: ${divideEndTime - divideStartTime} ms`);
}

function cos_Test() {
    let result;
    const cosStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.cos(-1);
    }
    const cosEndTime = Date.now();
    if (result.toFixed(6).toString() != '0.540302') {
        throw Error('math-cos error');
    }
    print(`math-cos: ${cosEndTime - cosStartTime} ms`);
}

function compare_Test() {
    let result;
    const compareStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.compare(15, 2);
    }
    const compareEndTime = Date.now();
    if (result.toString() != '1') {
        throw Error('math-compare error');
    }
    print(`math-compare: ${compareEndTime - compareStartTime} ms`);
}

function atan_Test() {
    let result;
    const atanStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.atan(1.5);
    }
    const atanEndTime = Date.now();
    if (result.toFixed(6).toString() != '0.982794') {
        throw Error('math-atan error');
    }
    print(`math-atan: ${atanEndTime - atanStartTime} ms`);
}

function asin_Test() {
    let result;
    const asinStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.asin(-1);
    }
    const asinEndTime = Date.now();
    if (result.toFixed(6).toString() != '-1.570796') {
        throw Error('math-asin error');
    }
    print(`math-asin: ${asinEndTime - asinStartTime} ms`);
}

function add_Test() {
    let result;
    const addStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.add(1234567890, 1987654321);
    }
    const addEndTime = Date.now();
    if (result.toString() != '3222222211') {
        throw Error('math-add error');
    }
    print(`math-add: ${addEndTime - addStartTime} ms`);
}

function acos_Test() {
    let result;
    const acosStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.acos(-1);
    }
    const acosEndTime = Date.now();
    if (result.toFixed(6).toString() != '3.141593') {
        throw Error('math-acos error');
    }
    print(`math-acos: ${acosEndTime - acosStartTime} ms`);
}

function abs_Test() {
    let result;
    const absStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.abs(-9);
    }
    const absEndTime = Date.now();
    if (result.toString() != '9') {
        throw Error('math-abs error');
    }
    print(`math-abs: ${absEndTime - absStartTime} ms`);
}

function pow_Test() {
    let result;
    const powStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.pow(17, 5);
    }
    const powEndTime = Date.now();
    if (result.toString() != '1419857') {
        throw Error('math-pow error');
    }
    print(`math-pow: ${powEndTime - powStartTime} ms`);
}

function log10_Test() {
    let result;
    const mathLog10StartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.log10(1000000000);
    }
    const mathLog10EndTime = Date.now();
    if (result.toString() != '9') {
        throw Error('math-log10 error');
    }
    print(`math-log10: ${mathLog10EndTime - mathLog10StartTime} ms`);
}

function log1p_Test() {
    let result;
    const mathLog1pStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.log1p(100);
    }
    const mathLog1pEndTime = Date.now();
    if (result.toFixed(6).toString() != '4.615121') {
        throw Error('math-log1p error');
    }
    print(`math-log1p: ${mathLog1pEndTime - mathLog1pStartTime} ms`);
}

function hypot_Test() {
    let result;
    const hypotStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.hypot(2, 3, 4);
    }
    const hypotEndTime = Date.now();
    if (result.toFixed(6).toString() != '5.385165') {
        throw Error('math-hypot error');
    }
    print(`math-hypot: ${hypotEndTime - hypotStartTime} ms`);
}

function cosh_Test() {
    let result;
    const mathCoshStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.cosh(5);
    }
    const mathCoshEndTime = Date.now();
    if (result.toFixed(6).toString() != '74.209949') {
        throw Error('math-cosh error');
    }
    print(`math-cosh: ${mathCoshEndTime - mathCoshStartTime} ms`);
}

function ceil_Test() {
    let result;
    const ceilStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.ceil(3.3);
    }
    const ceilEndTime = Date.now();
    if (result.toString() != '4') {
        throw Error('math-ceil error');
    }
    print(`math-ceil: ${ceilEndTime - ceilStartTime} ms`);
}

function cbrt_Test() {
    let result;
    const cbrtStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.cbrt(1860867);
    }
    const cbrtEndTime = Date.now();
    if (result.toString() != '123') {
        throw Error('math-cbrt error');
    }
    print(`math-cbrt: ${cbrtEndTime - cbrtStartTime} ms`);
}

function atanh_Test() {
    let result;
    const atanhStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.atanh(0.5);
    }
    const atanhEndTime = Date.now();
    if (result.toFixed(6).toString() != '0.549306') {
        throw Error('math-atanh error');
    }
    print(`math-atanh: ${atanhEndTime - atanhStartTime} ms`);
}

function acosh_Test() {
    let result;
    const acoshStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.acosh(3);
    }
    const acoshEndTime = Date.now();
    if (result.toFixed(6).toString() != '1.762747') {
        throw Error('math-acosh error');
    }
    print(`math-acosh: ${acoshEndTime - acoshStartTime} ms`);
}

function log2_Test() {
    let result;
    const log2StartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.log2(2147483648);
    }
    const log2EndTime = Date.now();
    if (result.toString() != '31') {
        throw Error('math-log2 error');
    }
    print(`math-log2: ${log2EndTime - log2StartTime} ms`);
}

function asinh_Test() {
    let result;
    const asinhStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.asinh(1);
    }
    const asinhEndTime = Date.now();
    if (result.toFixed(6).toString() != '0.881374') {
        throw Error('math-asinh error');
    }
    print(`math-asinh: ${asinhEndTime - asinhStartTime} ms`);
}

function sinh_Test() {
    let result;
    const sinhStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.sinh(1);
    }
    const sinhEndTime = Date.now();
    if (result.toFixed(6).toString() != '1.175201') {
        throw Error('math-sinh error');
    }
    print(`math-sinh: ${sinhEndTime - sinhStartTime} ms`);
}

function tanh_Test() {
    let result;
    const tanhStartTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.tanh(1);
    }
    const tanhEndTime = Date.now();
    if (result.toFixed(6).toString() != '0.761594') {
        throw Error('math-tanh error');
    }
    print(`math-tanh: ${tanhEndTime - tanhStartTime} ms`);
}

function qr_Test() {
    let result;
    const qrStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.qr([[10, 1, 10], [1, 10, 1], [10, 1, 10]]);
    }
    const qrEndTime = Date.now();
    if (JSON.stringify(result) != '{"Q":[[0.7053456158585985,-0.04987546680538167,-0.7071067811865475],[0.07053456158585983,0.9975093361076327,-2.7755575615628914e-17],[0.7053456158585982,-0.04987546680538163,0.7071067811865477]],"R":[[14.177446878757824,2.1160368475757947,14.177446878757824],[0,9.875342427465567,1.6999732080083245e-16],[0,0,1.7820910017114443e-15]]}') {
        throw Error('math-qr error');
    }
    print(`math-qr: ${qrEndTime - qrStartTime} ms`);
}

function zeros_Test() {
    let result;
    const zerosStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.zeros(2, 3);
    }
    const zerosEndTime = Date.now();
    if (result.toString() != '[[0, 0, 0], [0, 0, 0]]') {
        throw Error('math-zeros error');
    }
    print(`math-zeros: ${zerosEndTime - zerosStartTime} ms`);
}

function trace_Test() {
    let result;
    const traceStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.trace([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
    }
    const traceEndTime = Date.now();
    if (result.toString() != '15') {
        throw Error('math-trace error');
    }
    print(`math-trace: ${traceEndTime - traceStartTime} ms`);
}

function subset_Test() {
    let result;
    const mathIndex = math.index(1, 0);
    const subsetStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.subset([[10, 1, 10], [1, 10, 1], [10, 1, 10]], mathIndex);
    }
    const subsetEndTime = Date.now();
    if (result.toString() != '1') {
        throw Error('math-subset error');
    }
    print(`math-subset: ${subsetEndTime - subsetStartTime} ms`);
}

function squeeze_Test() {
    let result;
    const squeezeStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.squeeze([[10, 1, 10], [1, 10, 1], [10, 1, 10]]);
    }
    const squeezeEndTime = Date.now();
    if (JSON.stringify(result) != '[[10,1,10],[1,10,1],[10,1,10]]') {
        throw Error('math-squeeze error');
    }
    print(`math-squeeze: ${squeezeEndTime - squeezeStartTime} ms`);
}

function sort_Test() {
    let result;
    const sortStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.sort([5, 10, 1, -5, -1]);
    }
    const sortEndTime = Date.now();
    if (JSON.stringify(result) != '[-5,-1,1,5,10]') {
        throw Error('math-sort error');
    }
    print(`math-sort: ${sortEndTime - sortStartTime} ms`);
}

function size_Test() {
    let result;
    const sizeStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.size([[10, 1, 10], [1, 10, 1], [10, 1, 10]]);
    }
    const sizeEndTime = Date.now();
    if (JSON.stringify(result) != '[3,3]') {
        throw Error('math-size error');
    }
    print(`math-size: ${sizeEndTime - sizeStartTime} ms`);
}

function resize_Test() {
    let result;
    const rowStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.resize([[10, 1, 10], [1, 10, 1], [10, 1, 10]], [2, 1]);
    }
    const rowEndTime = Date.now();
    if (JSON.stringify(result) != '[[10],[1]]') {
        throw Error('math-resize error');
    }
    print(`math-resize: ${rowEndTime - rowStartTime} ms`);
}

function reshape_Test() {
    let result;
    const reshapeStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.reshape([1, 2, 3, 4, 5, 6], [3, 2]);
    }
    const reshapeEndTime = Date.now();
    if (JSON.stringify(result) != '[[1,2],[3,4],[5,6]]') {
        throw Error('math-reshape error');
    }
    print(`math-reshape: ${reshapeEndTime - reshapeStartTime} ms`);
}

function range_Test() {
    let result;
    const rangeStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.range(-5, 5);
    }
    const rangeEndTime = Date.now();
    if (result.toString() != '[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]') {
        throw Error('math-range error');
    }
    print(`math-range: ${rangeEndTime - rangeStartTime} ms`);
}

function ones_Test() {
    let result;
    const onesStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.ones(3, 2);
    }
    const onesEndTime = Date.now();
    if (result.toString() != '[[1, 1], [1, 1], [1, 1]]') {
        throw Error('math-ones error');
    }
    print(`math-ones: ${onesEndTime - onesStartTime} ms`);
}

function kron_Test() {
    let result;
    const kronStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.kron([[10, 1, 10], [1, 10, 1], [10, 1, 10]], [[2, 2], [2, 2]]);
    }
    const kronEndTime = Date.now();
    if (JSON.stringify(result) != '[[20,20,2,2,20,20],[20,20,2,2,20,20],[2,2,20,20,2,2],[2,2,20,20,2,2],[20,20,2,2,20,20],[20,20,2,2,20,20]]') {
        throw Error('math-kron error');
    }
    print(`math-kron: ${kronEndTime - kronStartTime} ms`);
}

function inv_Test() {
    let result;
    const invStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.inv([[1, 2], [3, 4]]);
    }
    const invEndTime = Date.now();
    if (JSON.stringify(result) != '[[-2,1],[1.5,-0.5]]') {
        throw Error('math-inv error');
    }
    print(`math-inv: ${invEndTime - invStartTime} ms`);
}

function identity_Test() {
    let result;
    const identityStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.identity(3, 3);
    }
    const identityEndTime = Date.now();
    if (result.toString() != '[[1, 0, 0], [0, 1, 0], [0, 0, 1]]') {
        throw Error('math-identity error');
    }
    print(`math-identity: ${identityEndTime - identityStartTime} ms`);
}

function flatten_Test() {
    let result;
    const flattenStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.flatten([[10, 1, 10], [1, 10, 1], [10, 1, 10]]);
    }
    const flattenEndTime = Date.now();
    if (JSON.stringify(result) != '[10,1,10,1,10,1,10,1,10]') {
        throw Error('math-flatten error');
    }
    print(`math-flatten: ${flattenEndTime - flattenStartTime} ms`);
}

function fft_Test() {
    let result;
    const fftStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.fft([[10, 2], [2, 10]]);
    }
    const fftEndTime = Date.now();
    if (result.toString() != '24,0,0,16') {
        throw Error('math-fft error');
    }
    print(`math-fft: ${fftEndTime - fftStartTime} ms`);
}

function expm_Test() {
    let result;
    const expmStartTime = Date.now();
    for (let index = 0; index < 100; index++) {
        result = math.expm([[10, 1], [1, 10]]);
    }
    const expmEndTime = Date.now();
    if (result.toString() != '[[33988.612821386436, 25885.528893811086], [25885.528893811086, 33988.612821386436]]') {
        throw Error('math-expm error');
    }
    print(`math-expm: ${expmEndTime - expmStartTime} ms`);
}

function dot_Test() {
    let result;
    const dotStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.dot([1, 2, 3, 4, 5], [6, 7, 8, 9, 0]);
    }
    const dotEndTime = Date.now();
    if (result.toString() != '80') {
        throw Error('math-dot error');
    }
    print(`math-dot: ${dotEndTime - dotStartTime} ms`);
}

function diag_Test_01() {
    let result;
    const diagStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.diag([1, 2, 3, 4, 5]);
    }
    const diagEndTime = Date.now();
    if (JSON.stringify(result) != '[[1,0,0,0,0],[0,2,0,0,0],[0,0,3,0,0],[0,0,0,4,0],[0,0,0,0,5]]') {
        throw Error('math-diag(one-dimensional array) error');
    }
    print(`math-diag(one-dimensional array): ${diagEndTime - diagStartTime} ms`);
}

function diag_Test_02() {
    let result;
    const diagStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.diag([[10, 1, 10], [1, 10, 1], [10, 1, 10]]);
    }
    const diagEndTime = Date.now();
    if (JSON.stringify(result) != '[10,10,10]') {
        throw Error('math-diag(two-dimensional array) error');
    }
    print(`math-diag(two-dimensional array): ${diagEndTime - diagStartTime} ms`);
}

function det_Test() {
    let result;
    const detStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.det([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
    }
    const detEndTime = Date.now();
    if (result.toString() != '0') {
        throw Error('math-det error');
    }
    print(`math-det: ${detEndTime - detStartTime} ms`);
}

function cross_Test() {
    let result;
    const crossStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.cross([10, 1, 10], [1, 2, 3]);
    }
    const crossEndTime = Date.now();
    if (JSON.stringify(result) != '[-17,-20,19]') {
        throw Error('math-cross error');
    }
    print(`math-cross: ${crossEndTime - crossStartTime} ms`);
}

function count_Test() {
    let result;
    const countStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.count([[10, 1, 10], [1, 10, 1], [10, 1, 10]]);
    }
    const countEndTime = Date.now();
    if (result.toString() != '9') {
        throw Error('math-count error');
    }
    print(`math-count: ${countEndTime - countStartTime} ms`);
}

function concat_Test() {
    let result;
    const concatStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.concat([[10, 1, 10], [1, 10, 1], [10, 1, 10]], [[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
    }
    const concatEndTime = Date.now();
    if (JSON.stringify(result) != '[[10,1,10,1,2,3],[1,10,1,4,5,6],[10,1,10,7,8,9]]') {
        throw Error('math-concat error');
    }
    print(`math-concat: ${concatEndTime - concatStartTime} ms`);
}

function column_Test() {
    let result;
    const columnStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.column([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 0);
    }
    const columnEndTime = Date.now();
    if (JSON.stringify(result) != '[[1],[4],[7]]') {
        throw Error('math-column error');
    }
    print(`math-column: ${columnEndTime - columnStartTime} ms`);
}

function apply_Test() {
    let result;
    const applyStartTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.apply([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1, math.sum);
    }
    const applyEndTime = Date.now();
    if (JSON.stringify(result) != '[6,15,24]') {
        throw Error('math-apply error');
    }
    print(`math-apply: ${applyEndTime - applyStartTime} ms`);
}

function typeOf_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.typeOf(new Date());
    }
    const endTime = Date.now();
    if (result.toString() != 'Date') {
        throw Error('math-typeOf error');
    }
    print(`math-typeOf: ${endTime - startTime} ms`);
}

function clone_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10; index++) {
        result = math.clone(mathData);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != JSON.stringify(mathData)) {
        throw Error('math-clone error');
    }
    print(`math-clone: ${endTime - startTime} ms`);
}

function isUndefined_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 1000000; index++) {
        result = math.isUndefined(undefined);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-isUndefined error');
    }
    print(`math-isUndefined: ${endTime - startTime} ms`);
}

function isNull_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 1000000; index++) {
        result = math.isNull(null);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-isNull error');
    }
    print(`math-isNull: ${endTime - startTime} ms`);
}

function isObject_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.isObject(new Object());
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-isObject error');
    }
    print(`math-isObject: ${endTime - startTime} ms`);
}

function isRegExp_Test() {
    let result;
    const mathRegExp = new RegExp('/^[abc]$/');
    const startTime = Date.now();
    for (let index = 0; index < 1000000; index++) {
        result = math.isRegExp(mathRegExp);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-isRegExp error');
    }
    print(`math-isRegExp: ${endTime - startTime} ms`);
}

function isDate_Test() {
    let result;
    const mathDate = new Date('12/30');
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.isDate(mathDate);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-isDate error');
    }
    print(`math-isDate: ${endTime - startTime} ms`);
}

function isFunction_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.isFunction((n) => {return true;});
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-isFunction error');
    }
    print(`math-isFunction: ${endTime - startTime} ms`);
}

function isBoolean_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 1000000; index++) {
        result = math.isBoolean(true);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-isBoolean error');
    }
    print(`math-isBoolean: ${endTime - startTime} ms`);
}

function to_Test() {
    let result;
    const mathUnit = math.unit(16, 'bytes');
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.to(mathUnit, 'bits');
    }
    const endTime = Date.now();
    if (result.toString() != '128 bits') {
        throw Error('math-to error');
    }
    print(`math-to: ${endTime - startTime} ms`);
}

function sech_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.sech(1);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '0.648054') {
        throw Error('math-sech error');
    }
    print(`math-sech: ${endTime - startTime} ms`);
}

function sec_Test() {
    let result;
    const mathSec = math.pi / 4;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.sec(mathSec);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '1.414214') {
        throw Error('math-sec error');
    }
    print(`math-sec: ${endTime - startTime} ms`);
}

function csch_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.csch(0.5);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '1.919035') {
        throw Error('math-csch error');
    }
    print(`math-csch: ${endTime - startTime} ms`);    
}

function csc_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.csc(math.pi / 2);
    }
    const endTime = Date.now();
    if (result.toString() != '1') {
        throw Error('math-csc error');
    }
    print(`math-csc: ${endTime - startTime} ms`);
}

function coth_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.coth(1);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '1.313035') {
        throw Error('math-coth error');
    }
    print(`math-coth: ${endTime - startTime} ms`);
}

function cot_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.cot(math.pi / 4);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '1.000000') {
        throw Error('math-cot error');
    }
    print(`math-cot: ${endTime - startTime} ms`);
}

function asech_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.asech(0.5);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '1.316958') {
        throw Error('math-asech error');
    }
    print(`math-asech: ${endTime - startTime} ms`);
}

function asec_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.asec(2);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '1.047198') {
        throw Error('math-asec error');
    }
    print(`math-asec: ${endTime - startTime} ms`);
}

function acsch_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.acsch(0.5);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '1.443635') {
        throw Error('math-acsch error');
    }
    print(`math-acsch: ${endTime - startTime} ms`);
}

function acsc_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.acsc(45);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '0.022224') {
        throw Error('math-acsc error');
    }
    print(`math-acsc: ${endTime - startTime} ms`);
}

function acoth_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.acoth(1.5);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '0.804719') {
        throw Error('math-acoth error');
    }
    print(`math-acoth: ${endTime - startTime} ms`);
}

function acot_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.acot(1);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '0.785398') {
        throw Error('math-acot error');
    }
    print(`math-acot: ${endTime - startTime} ms`);
}

function std_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.std([1, 2, 3, 4, 5], 0, 'biased');
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '1.290994') {
        throw Error('math-std error');
    }
    print(`math-std: ${endTime - startTime} ms`);
}

function quantileSeq_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.quantileSeq([1, 2, 3, 4, 5], 0.5, true);
    }
    const endTime = Date.now();
    if (result.toString() != '3') {
        throw Error('math-quantileSeq error');
    }
    print(`math-quantileSeq: ${endTime - startTime} ms`);
}

function median_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.median([1, -2, -3, 4, 5]);
    }
    const endTime = Date.now();
    if (result.toString() != '1') {
        throw Error('math-median error');
    }
    print(`math-median: ${endTime - startTime} ms`);
}

function erf_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.erf(1);
    }
    const endTime = Date.now();
    if (result.toFixed(6).toString() != '0.842701') {
        throw Error('math-erf error');
    }
    print(`math-erf: ${endTime - startTime} ms`);
}

function setUnion_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.setUnion([1, 2, 3], [-2, 3, 4]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[1,2,-2,4,3]') {
        throw Error('math-setUnionerror');
    }
    print(`math-setUnion: ${endTime - startTime} ms`);
}

function setSymDifference_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.setSymDifference([1, -2, 3], [3, 4]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[-2,1,4]') {
        throw Error('math-setSymDifference error');
    }
    print(`math-setSymDifference: ${endTime - startTime} ms`);
}

function setPowerset_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.setPowerset([-1, 2]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[[],[-1],[2],[-1,2]]') {
        throw Error('math-setPowerset error');
    }
    print(`math-setPowerset: ${endTime - startTime} ms`);
}

function setIsSubset_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.setIsSubset([1, 2], [1, 2, 3]);
    }
    const endTime = Date.now();
    if (result.toString() != 'true') {
        throw Error('math-setIsSubset error');
    }
    print(`math-setIsSubset: ${endTime - startTime} ms`);
}

function setDifference_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.setDifference([1, 2, 3], [-2, 3, 4]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[1,2]') {
        throw Error('math-setDifference error');
    }
    print(`math-setDifference: ${endTime - startTime} ms`);
}

function setCartesian_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.setCartesian([-1, -2], [3, 4]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[[-2,3],[-2,4],[-1,3],[-1,4]]') {
        throw Error('math-setCartesian error');
    }
    print(`math-setCartesian: ${endTime - startTime} ms`);
}

function setDistinct_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.setDistinct([[3, 2, 1], [3, 5, 4], [6, 2, 8], [7, 9, 5]]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[1,2,3,4,5,6,7,8,9]') {
        throw Error('math-setDistinct error');
    }
    print(`math-setDistinct: ${endTime - startTime} ms`);
}

function unequal_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.unequal('5', 6);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-unequal error');
    }
    print(`math-unequal: ${endTime - startTime} ms`);
}

function smallerEq_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.smallerEq('5', 2 + 3);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-smallerEq error');
    }
    print(`math-smallerEq: ${endTime - startTime} ms`);
}

function smaller_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.smaller('5', 2 + 4);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-smaller error');
    }
    print(`math-smaller: ${endTime - startTime} ms`);
}

function arg_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.arg([[2, 3], [1, 4]]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[[0,0],[0,0]]') {
        throw Error('math-arg error');
    }
    print(`math-arg: ${endTime - startTime} ms`);
}

function stirlingS2_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.stirlingS2(9, 3);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '3025') {
        throw Error('math-stirlingS2 error');
    }
    print(`math-stirlingS2: ${endTime - startTime} ms`);
}

function composition_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.composition(2132, 3);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '2269515') {
        throw Error('math-composition error');
    }
    print(`math-composition: ${endTime - startTime} ms`);
}

function catalan_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.catalan(24);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '1289904147324') {
        throw Error('math-catalan error');
    }
    print(`math-catalan: ${endTime - startTime} ms`);
}

function unaryPlus_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.unaryPlus([4134244, '89218492', true, [5, 6, 7]]);
    }
    const endTime = Date.now();
    
    if (JSON.stringify(result) != '[4134244,89218492,1,[5,6,7]]') {
        throw Error('math-unaryPlus error');
    }
    print(`math-unaryPlus: ${endTime - startTime} ms`);
}

function sign_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.sign([-3, 0, 3, 7, -7]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[-1,0,1,1,-1]') {
        throw Error('math-sign error');
    }
    print(`math-sign: ${endTime - startTime} ms`);
}

function nthRoot_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.nthRoot(60466176, 10);
    }
    const endTime = Date.now();
    if (JSON.stringify(math.floor(result)) != '6') {
        throw Error('math-nthRoot error');
    }
    print(`math-nthRoot: ${endTime - startTime} ms`);
}

function norm_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.norm(-4);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '4') {
        throw Error('math-norm error');
    }
    print(`math-norm: ${endTime - startTime} ms`);
}

function mod_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.mod(36829745909879, 4);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '3') {
        throw Error('math-mod error');
    }
    print(`math-mod: ${endTime - startTime} ms`);
}

function lcm_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.lcm([[121, 245], [377, 493]], [[564, 67], [73, 890]]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[[68244,16415],[27521,438770]]') {
        throw Error('math-lcm error');
    }
    print(`math-lcm: ${endTime - startTime} ms`);
}

function gcd_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.gcd([[1, 2], [3, 4]], [[5, 6], [7, 8]]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[[1,2],[1,4]]') {
        throw Error('math-gcd error');
    }
    print(`math-gcd: ${endTime - startTime} ms`);
}

function expm1_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 1000000; index++) {
        result = math.expm1(20);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '485165194.4097903') {
        throw Error('math-expm1 error');
    }
    print(`math-expm1: ${endTime - startTime} ms`);
}

function dotPow_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.dotPow([2, 3, 4, 5, 6, 7], 10);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[1024,59049,1048576,9765625,60466176,282475249]') {
        throw Error('math-dotPow error');
    }
    print(`math-dotPow: ${endTime - startTime} ms`);
}

function dotMultiply_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.dotMultiply([2, 3, 4, 5, 6, 7], [10, 9, 8, 7, 6, 5]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[20,27,32,35,36,35]') {
        throw Error('math-dotMultiply error');
    }
    print(`math-dotMultiply: ${endTime - startTime} ms`);
}

function dotDivide_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.dotDivide([10, 9, 8, 245, 6, 21], [2, 3, 4, 5, 6, 7]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[5,3,2,49,1,3]') {
        throw Error('math-dotDivide error');
    }
    print(`math-dotDivide: ${endTime - startTime} ms`);
}

function cube_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.cube(37);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '50653') {
        throw Error('math-cube error');
    }
    print(`math-cube: ${endTime - startTime} ms`);
}

function floor_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.floor(-0.95736, 2);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '-0.96') {
        throw Error('math-floor error');
    }
    print(`math-floor: ${endTime - startTime} ms`);
}

function fix_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.fix(-0.95736, 2);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '-0.95') {
        throw Error('math-fix error');
    }
    print(`math-fix: ${endTime - startTime} ms`);
}

function larger_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.larger('5', 2);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-larger error');
    }
    print(`math-larger: ${endTime - startTime} ms`);
}

function largerEq_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.largerEq('5', 5);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-largerEq error');
    }
    print(`math-largerEq: ${endTime - startTime} ms`);
}

function equalText_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.equalText('apple', 'orange');
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'false') {
        throw Error('math-equalText error');
    }
    print(`math-equalText: ${endTime - startTime} ms`);
}

function equal_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.equal(2 * 2, 4);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-equal error');
    }
    print(`math-equal: ${endTime - startTime} ms`);
}

function deepEqual_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.deepEqual([1, 2, 3], [1, 2, 3]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != 'true') {
        throw Error('math-deepEqual error');
    }
    print(`math-deepEqual: ${endTime - startTime} ms`);
}

function compareText_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.compareText('apple', 'orange');
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '-1') {
        throw Error('math-compareText error');
    }
    print(`math-compareText: ${endTime - startTime} ms`);
}

function compareNatural_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.compareNatural('apple', 'orange');
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '-1') {
        throw Error('math-compareNatural error');
    }
    print(`math-compareNatural: ${endTime - startTime} ms`);
}

function permutations_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.permutations(4, 3);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '24') {
        throw Error('math-permutations error');
    }
    print(`math-permutations: ${endTime - startTime} ms`);
}

function multinomial_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.multinomial([1, 2, 3, 4]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '12600') {
        throw Error('math-multinomial error');
    }
    print(`math-multinomial: ${endTime - startTime} ms`);
}

function lgamma_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.lgamma(7);
    }
    const endTime = Date.now();
    if (result.toFixed(6) != '6.579251') {
        throw Error('math-lgamma error');
    }
    print(`math-lgamma: ${endTime - startTime} ms`);
}

function kldivergence_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.kldivergence([8, 3], [6, 2]);
    }
    const endTime = Date.now();
    if (result.toFixed(6) != '0.001351') {
        throw Error('math-kldivergence error');
    }
    print(`math-kldivergence: ${endTime - startTime} ms`);
}

function gamma_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.gamma(7);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '720') {
        throw Error('math-gamma error');
    }
    print(`math-gamma: ${endTime - startTime} ms`);
}

function factorial_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.factorial([[1, 2], [3, 4], [5, 6]]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[[1,2],[6,24],[120,720]]') {
        throw Error('math-factorial error');
    }
    print(`math-factorial: ${endTime - startTime} ms`);
}

function combinations_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.combinations(5, 2);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '10') {
        throw Error('math-combinations error');
    }
    print(`math-combinations: ${endTime - startTime} ms`);
}

function sqrtm_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100; index++) {
        result = math.sqrtm([[7, 10], [15, 22]]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[[1.5666989036012802,1.7407765595569775],[2.6111648393354665,4.177863742936745]]') {
        throw Error('math-sqrtm error');
    }
    print(`math-sqrtm: ${endTime - startTime} ms`);
}

function rotate_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.rotate([3, 6], 1);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[-3.4279189912429593,5.766226789632528]') {
        throw Error('math-rotate error');
    }
    print(`math-rotate: ${endTime - startTime} ms`);
}

function partitionSelect_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.partitionSelect([[1, 2], [3, 4], [5, 6], [7, 8]], 0);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[1,2]') {
        throw Error('math-partitionSelect error');
    }
    print(`math-partitionSelect: ${endTime - startTime} ms`);
}

function not_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.not([7, 8]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[false,false]') {
        throw Error('math-not error');
    }
    print(`math-not: ${endTime - startTime} ms`);
}

function or_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.or([7, 8], [1, 2]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[true,true]') {
        throw Error('math-or error');
    }
    print(`math-or: ${endTime - startTime} ms`);
}

function and_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.and([7, 1], [4, 3]);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[true,true]') {
        throw Error('math-and error');
    }
    print(`math-and: ${endTime - startTime} ms`);
}

function bellNumbers_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.bellNumbers(8);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '4140') {
        throw Error('math-bellNumbers error');
    }
    print(`math-bellNumbers: ${endTime - startTime} ms`);
}

function rightLogShift_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 10000; index++) {
        result = math.rightLogShift([4, 3], 2);
    }
    const endTime = Date.now();
    if (JSON.stringify(result) != '[1,0]') {
        throw Error('math-rightLogShift error');
    }
    print(`math-rightLogShift: ${endTime - startTime} ms`);
}

function isString_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.isString('1 + 2');
    }
    const endTime = Date.now();
    if (result != true) {
        throw Error('math-isString error');
    }
    print(`math-isString: ${endTime - startTime} ms`);
}

function unit_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 1000; index++) {
        result = math.unit('5 m/s');
    }
    const endTime = Date.now();
    if (result.toString() != '5 m / s') {
        throw Error('math-unit error');
    }
    print(`math-unit: ${endTime - startTime} ms`);
}

function isUnit_Test() {
    const unit = math.unit('5 m/s');
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.isUnit(unit);
    }
    const endTime = Date.now();
    if (result != true) {
        throw Error('math-isUnit error');
    }
    print(`math-isUnit: ${endTime - startTime} ms`);
}

function fraction_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 30000; index++) {
        result = math.fraction(1, -2);
    }
    const endTime = Date.now();
    if (result != -0.5) {
        throw Error('math-fraction error');
    }
    print(`math-fraction: ${endTime - startTime} ms`);
}

function isFraction_Test() {
    const fraction = math.fraction(1, -2);
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.isFraction(fraction);
    }
    const endTime = Date.now();
    if (result != true) {
        throw Error('math-isFraction error');
    }
    print(`math-isFraction: ${endTime - startTime} ms`);
}

function complex_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 30000; index++) {
        result = math.complex(2, -3);
    }
    const endTime = Date.now();
    if (result.toString() != '2 - 3i') {
        throw Error('math-complex error');
    }
    print(`math-complex: ${endTime - startTime} ms`);
}

function isComplex_Test() {
    const complex = math.complex(2, -3);
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.isComplex(complex);
    }
    const endTime = Date.now();
    if (result != true) {
        throw Error('math-isComplex error');
    }
    print(`math-isComplex: ${endTime - startTime} ms`);
}

function bignumber_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.bignumber(1234567891234223);
    }
    const endTime = Date.now();
    if (result.toString() != '1234567891234223') {
        throw Error('math-bignumber error');
    }
    print(`math-bignumber: ${endTime - startTime} ms`);
}

function isBigNumber_Test() {
    const bignumber = math.bignumber(1234567891234223);
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 100000; index++) {
        result = math.isBigNumber(bignumber);
    }
    const endTime = Date.now();
    if (result != true) {
        throw Error('math-isBigNumber error');
    }
    print(`math-isBigNumber: ${endTime - startTime} ms`);
}

function ifft_Test() {
    let result;
    const startTime = Date.now();
    for (let index = 0; index < 1000; index++) {
        result = math.ifft([[1, 2], [3, 4]]);
    }
    const endTime = Date.now();
    if (result.toString() != '2.5,-0.5,-1,0') {
        throw Error('math-ifft error');
    }
    print(`math-ifft: ${endTime - startTime} ms`);
}

bitAnd_Test();
bitNot_Test();
bitOr_Test();
bitXor_Test();
isZero_Test();
isPrime_Test();
isNumeric_Test();
isNaN_Test();
isInteger_Test();
hasNumericValue_Test();
variance_Test();
sum_Test();
prod_Test();
mean_Test();
mad_Test();
cumsum_Test();
isNegative_Test();
isPositive_Test();
unaryMinus_Test();
tan_Test();
subtract_Test();
sqrt_Test();
sin_Test();
round_Test();
rightArithShift_Test();
multiply_Test();
min_Test();
max_Test();
log_Test();
leftShift_Test();
exp_Test();
divide_Test();
cos_Test();
compare_Test();
atan_Test();
asin_Test();
add_Test();
acos_Test();
abs_Test();
pow_Test();
log10_Test();
log1p_Test();
hypot_Test();
cosh_Test();
ceil_Test();
cbrt_Test();
atanh_Test();
acosh_Test();
log2_Test();
asinh_Test();
sinh_Test();
tanh_Test();
qr_Test();
zeros_Test();
trace_Test();
subset_Test();
squeeze_Test();
sort_Test();
size_Test();
resize_Test();
reshape_Test();
range_Test();
ones_Test();
kron_Test();
inv_Test();
identity_Test();
flatten_Test();
fft_Test();
expm_Test();
dot_Test();
diag_Test_01();
diag_Test_02();
det_Test();
cross_Test();
count_Test();
concat_Test();
column_Test();
apply_Test();
typeOf_Test();
clone_Test();
isUndefined_Test();
isNull_Test();
isObject_Test();
isRegExp_Test();
isDate_Test();
isFunction_Test();
isBoolean_Test();
to_Test();
sech_Test();
sec_Test();
csch_Test();
csc_Test();
coth_Test();
cot_Test();
asech_Test();
asec_Test();
acsch_Test();
acsc_Test();
acoth_Test();
acot_Test();
std_Test();
quantileSeq_Test();
median_Test();
erf_Test();
setUnion_Test();
setSymDifference_Test();
setPowerset_Test();
setIsSubset_Test();
setDifference_Test();
setCartesian_Test();
setDistinct_Test();
unequal_Test();
smallerEq_Test();
smaller_Test();
arg_Test();
stirlingS2_Test();
composition_Test();
catalan_Test();
unaryPlus_Test();
sign_Test();
nthRoot_Test();
norm_Test();
mod_Test();
lcm_Test();
gcd_Test();
expm1_Test();
dotPow_Test();
dotMultiply_Test();
dotDivide_Test();
cube_Test();
floor_Test();
fix_Test();
larger_Test();
largerEq_Test();
equalText_Test();
equal_Test();
deepEqual_Test();
compareText_Test();
compareNatural_Test();
permutations_Test();
multinomial_Test();
lgamma_Test();
kldivergence_Test();
gamma_Test();
factorial_Test();
combinations_Test();
sqrtm_Test();
rotate_Test();
partitionSelect_Test();
not_Test();
or_Test();
and_Test();
bellNumbers_Test();
rightLogShift_Test();
isString_Test();
unit_Test();
isUnit_Test();
fraction_Test();
isFraction_Test();
complex_Test();
isComplex_Test();
bignumber_Test();
isBigNumber_Test();
ifft_Test();

